package com.yh.workbill.view;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import com.wang.avi.AVLoadingIndicatorView;
import com.yh.workbill.R;


public class LoadProgressDialog extends Dialog {
    private String message;
    private boolean canCancel;
    private TextView textView;
    private AVLoadingIndicatorView avi;

    public LoadProgressDialog(Context context, String message) {
        this(context, message, true);
    }

    public LoadProgressDialog(Context context, String message, boolean canCancel) {
        super(context, R.style.LoadProgressDialog);
        this.message = message;
        this.canCancel = canCancel;
    }

    @SuppressLint("ResourceType")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loadprogress);
        textView = findViewById(R.id.tv_message);
        setCancelable(canCancel);
        avi = findViewById(R.id.avi);
        setCanceledOnTouchOutside(canCancel);
        textView.setText(message);
    }

    public void showLoadding() {
        if (avi != null) {
            avi.show();
        }
        this.show();
    }

    public void dismissLoadding() {
        if (avi != null) {
            avi.hide();
        }
        this.dismiss();
    }
}
